package component.fulltextsearch.index.handlingtypes;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hslf.extractor.PowerPointExtractor;


public class POIPowerPointHandler implements IInputStreamHandler {

	public String getText(InputStream is) throws InputStreamHandlerException {
		String bodyText = null;
		try {
			PowerPointExtractor powerPointExtractor = new PowerPointExtractor(is);
			bodyText =  powerPointExtractor.getText();		
		} catch (IOException e) {
			throw new InputStreamHandlerException("Cannot extract text from a Word document", e);
		}		
		return bodyText;
	}

	public static void main(String[] args) throws Exception {
		POIPowerPointHandler handler = new POIPowerPointHandler();
		String doc = handler.getText(new FileInputStream(new File(args[0])));
		System.out.println(doc);
	}
}
